<template>
  <div class="panel" :style="{ width: collapsed ? minWidth : width}">
    <div class="header">
      <el-button class="header-item" icon="el-icon-search" circle @click="trigger"></el-button>
      <div class="header-item title" :style="{ width: collapsed ? 0 : '30%'} ">Search</div>
    </div>
    <div class="content" :style="{display: collapsed?'none':''}">
      <slot name="content"></slot>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    minWidth: {
      default: '64px'
    },
    width: {
      default: '300px'
    }
  },
  data() {
    return {
      collapsed: false
    }
  },
  methods: {
    trigger() {
      this.collapsed = !this.collapsed
      this.$emit('collapaseChange', this.collapsed)
    },
    isCollapsed() {
      return this.collapsed
    }
  }
}
</script>

<style scoped>
  .header {
    padding: 9px;
    background: white;
  }

  .header-item {
    display: inline-block;
    overflow: hidden;
  }

  .title {
    vertical-align: middle;
    font-size: 20px;
    transition: ease-in-out 0.5s;
  }

  .panel {
    float: left;
    width: 20%;
    height: 100%;
    background: rgb(40, 160, 240);
    transition: ease-in-out 0.5s;
    overflow: hidden;
    -webkit-box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.2);
    -moz-box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.2);
    box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.2);
  }

</style>
